package cn.swufe.edu.stu.hw_tools.Cal;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import cn.swufe.edu.stu.hw_tools.R;

public class WXYJActivity extends AppCompatActivity {
    private Button btn;
    private TextView v1,v2,v3,v4,v5,v6;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wxyjactivity);
        btn = findViewById(R.id.CC4WXYJback);
        v1 = findViewById(R.id.CC4WXYJ21);
        v2 = findViewById(R.id.CC4WXYJ22);
        v3 = findViewById(R.id.CC4WXYJ23);
        v4 = findViewById(R.id.CC4WXYJ24);
        v5 = findViewById(R.id.CC4WXYJ25);
        v6 = findViewById(R.id.CC4WXYJ26);
        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        v1.setText(String.format("%.2f",bundle.getFloat("rate1",0.0f)));
        v2.setText(String.format("%.2f",bundle.getFloat("rate2",0.0f)));
        v3.setText(String.format("%.2f",bundle.getFloat("rate3",0.0f)));
        v4.setText(String.format("%.2f",bundle.getFloat("rate4",0.0f)));
        v5.setText(String.format("%.2f",bundle.getFloat("rate5",0.0f)));
        v6.setText(String.format("%.2f",bundle.getFloat("rate6",0.0f)));

        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                float rate1 = Float.parseFloat(String.format("%.2f",Float.parseFloat(v1.getText().toString())));
                float rate2 = Float.parseFloat(String.format("%.2f",Float.parseFloat(v2.getText().toString())));
                float rate3 = Float.parseFloat(String.format("%.2f",Float.parseFloat(v3.getText().toString())));
                float rate4 = Float.parseFloat(String.format("%.2f",Float.parseFloat(v4.getText().toString())));
                float rate5 = Float.parseFloat(String.format("%.2f",Float.parseFloat(v5.getText().toString())));
                float rate6 = Float.parseFloat(String.format("%.2f",Float.parseFloat(v6.getText().toString())));
                bundle.putFloat("rate1",rate1);
                bundle.putFloat("rate2",rate2);
                bundle.putFloat("rate3",rate3);
                bundle.putFloat("rate4",rate4);
                bundle.putFloat("rate5",rate5);
                bundle.putFloat("rate6",rate6);
                intent.putExtras(bundle);

                setResult(2,intent);
                finish();
            }
        });

    }


}